<?php
/**
 * Repository trida s rozsirujicimi operacemi pro entitu Operation.
 * 
 * @author David Dusek 
 */

namespace CMS\User\Models;

use Doctrine\ORM\EntityRepository;

class OperationRepository extends EntityRepository {
    /**
     * Ziskani existujicich operaci pro zadany zdroj.
     * @param Resource $resource
     * @return array 
     */
    public function getExistingOperations(Resource $resource) {
        $qb = $this->_em->createQueryBuilder();
        $query = $qb->select('o')
                    ->from("\CMS\User\Models\Operation", 'o')
                    ->where("o.resource = " . $resource->getId())
                    ->getQuery();
        
        return $query->getResult();
    }
}
